package com.weifly.egp.service;

import com.weifly.egp.gui.GuiMain;
import com.weifly.egp.service.config.GridConfigServiceImpl;
import com.weifly.egp.service.monitor.StockMonitorService;
import com.weifly.egp.service.monitor.StockMonitorServiceImpl;
import com.weifly.egp.service.stock.StockUpdateService;
import com.weifly.egp.service.trade.GridStockTradeService;
import com.weifly.egp.service.trade.JniStockTradeService;
import com.weifly.egp.service.trade.StockTradeService;

/**
 * Created by weijianxin on 2018/8/20.
 */
public class AppRunner {

    public static void main(String[] args){
        AppRunner app = new AppRunner();
        app.start();
    }

    private ServiceManager serviceManager;
    private GuiMain guiMain;

    private void start(){
        this.serviceManager = new ServiceManager();
        this.serviceManager.setGridConfigService(new GridConfigServiceImpl());
        this.serviceManager.setStockMonitorService(new StockMonitorServiceImpl());
        this.serviceManager.setStockUpdateService(new StockUpdateService());
        this.serviceManager.setStockTradeService(new JniStockTradeService());

        this.guiMain = new GuiMain();
        this.guiMain.setServiceManager(this.serviceManager);
        this.guiMain.render();

        this.serviceManager.getStockUpdateService().setStockMonitorService(this.serviceManager.getStockMonitorService());
        this.serviceManager.getStockUpdateService().setStockTradeService(this.serviceManager.getStockTradeService());
        this.serviceManager.getStockUpdateService().setGridConfigService(this.serviceManager.getGridConfigService());
        this.serviceManager.getStockUpdateService().startUpdateEveryTime();
    }
}
